//
//  HZFocusDoctorCell.m
//  MyDoctor
//
//  Created by Mac on 16/5/5.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZFocusDoctorCell.h"
#import "HZFocusDoctorModel.h"

#define kMargin 10

@interface HZFocusDoctorCell ()

@property (nonatomic, weak) UILabel *nameLabel;
@property (nonatomic, weak) UILabel *doctorLabel;
@property (nonatomic, weak) UILabel *hospitalLabel;
@property (nonatomic, weak) UILabel *addLabel;
@property (nonatomic, weak) UILabel *flowerLabel;
@property (nonatomic, weak) UILabel *starLabel;

@end

@implementation HZFocusDoctorCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setFocusDoctorModel:(HZFocusDoctorModel *)focusDoctorModel {
    _focusDoctorModel = focusDoctorModel;
    
    //赋值
    self.nameLabel.text = focusDoctorModel.doctor_name;
    self.doctorLabel.text = focusDoctorModel.doctor_title_name;
    self.hospitalLabel.text = focusDoctorModel.doctor_hospital_name;
    self.addLabel.text = [NSString stringWithFormat:@"%@",focusDoctorModel.operation_count];
    self.flowerLabel.text = [NSString stringWithFormat:@"%@",focusDoctorModel.flower];
    self.starLabel.text = [NSString stringWithFormat:@"%@",focusDoctorModel.banner];
  
}

- (void)setupUI {
    
    //图片
    UIImageView *iconView = [[UIImageView alloc] init];
    iconView.image = [UIImage imageNamed:@"name"];
    [self.contentView addSubview:iconView];

    //姓名
    UILabel *nameLabel = [[UILabel alloc] init];
//    nameLabel.text = @"张三";
    self.nameLabel = nameLabel;
    [self.contentView addSubview:nameLabel];
    
    //医生类别
    UILabel *doctorLabel = [[UILabel alloc] init];
//    doctorLabel.text = @"心理医生";
    self.doctorLabel = doctorLabel;
    doctorLabel.textColor = [UIColor darkGrayColor];
    [self.contentView addSubview:doctorLabel];
    
    //医院
    UILabel *hospitalLabel = [[UILabel alloc] init];
//    hospitalLabel.text = @"协和";
    self.hospitalLabel = hospitalLabel;
    hospitalLabel.textColor = [UIColor darkGrayColor];
    [self.contentView addSubview:hospitalLabel];
    
    //图片按钮
    UIButton *imageButton = [[UIButton alloc] init];
    [imageButton setImage:[UIImage imageNamed:@"jishiben"] forState:UIControlStateNormal];
    [self.contentView addSubview:imageButton];
    
    //加号按钮
    UIButton *addButton = [[UIButton alloc] init];
    [addButton setImage:[UIImage imageNamed:@"yuyueliang"] forState:UIControlStateNormal];
    [self.contentView addSubview:addButton];
    
    //加号label
    UILabel *addLabel = [[UILabel alloc] init];
//    addLabel.text = @"1";
    self.addLabel = addLabel;
    addLabel.textColor = [UIColor darkGrayColor];
    [self.contentView addSubview:addLabel];
    
    //鲜花按钮
    UIButton *flowerButton = [[UIButton alloc] init];
    [flowerButton setImage:[UIImage imageNamed:@"xianhua"] forState:UIControlStateNormal];
    [self.contentView addSubview:flowerButton];
    
    //鲜花label
    UILabel *flowerLabel = [[UILabel alloc] init];
//    flowerLabel.text = @"2";
    self.flowerLabel = flowerLabel;
    flowerLabel.textColor = [UIColor darkGrayColor];
    [self.contentView addSubview:flowerLabel];
    
    //星星按钮
    UIButton *starButton = [[UIButton alloc] init];
    [starButton setImage:[UIImage imageNamed:@"jinqi"] forState:UIControlStateNormal];
    [self.contentView addSubview:starButton];
    
    //星星label
    UILabel *starLabel = [[UILabel alloc] init];
//    starLabel.text = @"3";
    self.starLabel = starLabel;
    starLabel.textColor = [UIColor darkGrayColor];
    [self.contentView addSubview:starLabel];
    
    //箭头图片
    UIImageView *accView = [[UIImageView alloc] init];
    accView.image = [UIImage imageNamed:@"jt"];
    [self.contentView addSubview:accView];
    
    
    //约束
    
    //图片
    [iconView makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.offset(kMargin);
        make.height.width.equalTo(80);
    }];
    
    //姓名
    [nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconView);
        make.leading.equalTo(iconView.trailing).offset(kMargin);
    }];
    
    //医生类别
    [doctorLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel);
        make.leading.equalTo(nameLabel.trailing).offset(kMargin);
    }];
    
    //医院
    [hospitalLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel.bottom).offset(kMargin);
        make.leading.equalTo(nameLabel);
    }];
    
    //加号按钮
    [addButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hospitalLabel.bottom).offset(kMargin);
        make.leading.equalTo(hospitalLabel).offset(kMargin);
    }];
    
    //加号label
    [addLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(addButton);
        make.leading.equalTo(addButton.trailing);
    }];
    
    //鲜花按钮
    [flowerButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hospitalLabel.bottom).offset(kMargin);
        make.leading.equalTo(addButton.trailing).offset(5 * kMargin);
    }];
    
    //鲜花label
    [flowerLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(flowerButton);
        make.leading.equalTo(flowerButton.trailing);
    }];
    
    //星星按钮
    [starButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hospitalLabel.bottom).offset(kMargin);
        make.leading.equalTo(flowerButton.trailing).offset(5 * kMargin);
    }];
    
    //星星label
    [starLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(starButton);
        make.leading.equalTo(starButton.trailing);
    }];
    
    //箭头图片
    [accView makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.trailing.equalTo(self.contentView).offset(-kMargin);
    }];
    
    //图片按钮
    [imageButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.trailing.equalTo(accView.leading).offset(-kMargin);
        make.width.height.equalTo(40);
    }];
}



@end
